package com.young.shop.controller;

import com.young.shop.pojo.entity.OrderList;
import com.young.shop.pojo.entity.OrdersStatus;
import com.young.shop.service.impl.OrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/state")
public class OrderListByState extends BaseController {
    OrderServiceImpl orderService = new OrderServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //通过状态码查询订单列表
        try {
            OrdersStatus ordersStatus = convertParamsToEntity(req, OrdersStatus.class);
            List<OrderList> statusLists = orderService.OrderByZtList(ordersStatus.getStatus(), ordersStatus.getUserId());
//            int status = 2;
//            Long userId = 1L;
//            List<OrderList> statusLists = orderService.OrderByZtList(status,userId);
//            System.out.println(statusLists);
            writerSuccessResult(statusLists,resp);
        }catch (Exception e){
            writerErrorResult(e.getMessage(),resp);
        }
    }
}
